﻿@model Zor_Web.Models.Base.V_Zor_AnnualTask
@using Webdiyer.WebControls.Mvc;
@using Zor_Tools;
@{
    Layout = null;
}
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>年度计划任务管理</title>
    <link rel="stylesheet" type="text/css" href="~/Content/HPlus/css/bootstrap.min14ed.css">
    <link rel="stylesheet" type="text/css" href="~/Content/HPlus/css/font-awesome.min93e3.css">
    <link rel="stylesheet" type="text/css" href="~/Content/HPlus/css/animate.min.css">
    <link rel="stylesheet" type="text/css" href="~/Content/HPlus/css/style.min862f.css">
    <link rel="stylesheet" type="text/css" href="~/Content/HPlus/css/custom.css" />
    <link href="~/Content/LayerUI/src/css/layui.css" rel="stylesheet" />
    <link href="~/Content/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/LayerUI/src/css/layui.css" rel="stylesheet" />
    <link href="~/Content/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/Styles/zor.css" rel="stylesheet" />
    <!-- 框架必要 -->
    <script src="~/Content/Scripts/jquery/jquery-1.9.1.min.js"></script>
    <script src="~/Content/Scripts/learunui-framework.js"></script>
    <script src="~/Content/Scripts/Zor_AJax.js"></script>
    <!-- 消息提示 -->
    <script language='javascript' src='~/Content/layer/layer.js'></script>
    <!-- 日期选择器 -->
    <script src="~/Content/laydate/laydate.js"></script>
    <!-- 表单验证 -->
    <script src="~/Content/Scripts/JValidator.js"></script>
</head>
<body class="gray-bg">
    <div class="layui-tab layui-tab-brief main-tab-container ">

        <div class="col-sm-12 ct-padding">
            <div class="col-sm-8 ct-padding">
                <button id="btnAdd" class="layui-btn layui-btn layui-btn-small"><span class="glyphicon glyphicon-plus"></span> 新增</button>
                <button id="btnUpdate" class="layui-btn layui-btn-warm  layui-btn-small"><span class="glyphicon glyphicon-pencil"></span> 编辑</button>
                <button id="btnDelete" class="layui-btn layui-btn-danger  layui-btn-small"><span class="glyphicon glyphicon-trash"></span> 删除</button>
                <button id="btnSearchFull" class="layui-btn  layui-btn-normal layui-btn-small"><span class="glyphicon glyphicon-search"></span>查询</button>                
                <button id="btnRefresh" class="layui-btn layui-btn-blue layui-btn-small"><span class="glyphicon glyphicon-repeat"></span>刷新</button>
            </div>
        </div>
    </div>
    <div class="layui-tab-content">
        <table class="layui-table" lay-skin="line">
            <thead>
                <tr>
                    <th hidden></th>
                    <th></th>
                    <th>街道名称</th>
                    <th>计划登记户数（户）</th>
                    <th>计划税收收入（万元）</th>
                    <th>年度</th>
                    <th>录入时间</th>
                </tr>
            </thead>
            <tbody id="accordion">
                @foreach (var item in Model.PageData)
                    {
                    <tr>
                        <td hidden>@item.At_Id</td>
                        <td><input type="radio" name="chk" id="@item.At_Id" value="@item.At_Id" /></td>
                        <td>@item.Dt_Name</td>
                        <td hidden>@item.At_StreetName</td>
                        <td>@item.At_RegisteredPlan</td>
                        <td hidden>@item.At_RevenuePlan</td>
                        <td>@item.RevenuePlan</td>
                        <td>@item.At_Year</td>
                        <td>@TimeHelper.TimeStampToDateTime(item.At_CreateDate.ToString(), TimeHelper.ToTimeType.link_ymd)</td>
                    </tr>
                    }

            </tbody>
        </table>
        <div class="col-sm-12">
            <div class="col-sm-10">
                @Html.Pager(Model.PageData, new PagerOptions { PageIndexParameterName = "index", ContainerTagName = "ul", PrevPageText = "上页", NextPageText = "下页", FirstPageText = "首页", LastPageText = "尾页", CssClass = "pagination", PagerItemsSeperator = "", CurrentPagerItemWrapperFormatString = "<li class=\"active\"><a href=\"#\">{0}</a></li>", PagerItemWrapperFormatString = "<li>{0}</li>" }, new { id = "bootstrappager", @class = "pagination" })
            </div>
            <div class="col-sm-2 to-righjt">
                共 @Model.PageData.TotalItemCount 条记录，页 @Model.PageData.CurrentPageIndex/@Model.PageData.TotalPageCount
            </div>
        </div>
    </div>

    <!-- 模态 -->
    <div id="myModal" hidden data-backdrop="static">
        <div id="divfrom" class="layui-tab-content">
            <form method="get" class="form-horizontal m-t">
                <div class="layui-form-item" hidden>
                    <label class="col-sm-3 layui-form-label">Id：</label>
                    <div class="col-sm-9">
                        <input id="At_Id" type="text" class="form-control">
                    </div>
                </div>
                <div class="layui-form-item" id="divAt_StreetName">
                    <label class="col-sm-3 layui-form-label">
                        <nobr>街道办名称：</nobr>
                    </label>
                    <div class="col-sm-9">
                        <select name="temp" class="form-control" id="At_StreetName"></select>
                    </div>
                </div>               
                <div class="layui-form-item" id="divAt_Year">
                    <label class="col-sm-3 layui-form-label">
                        <nobr>年份：</nobr>
                    </label>
                    <div class="col-sm-9">
                        <select name="temp" class="form-control" id="At_Year">

                            @for (var i = DateTime.Now.Year; i <= DateTime.Now.Year + 12; i++)
                            {
                                <option value=@i>
                                    @i 年
                                </option>
                            }
                        </select>
                    </div>
                </div>               
                <div class="layui-form-item">
                    <label class="col-sm-3 layui-form-label">计划登记户：</label>
                    <div class="col-sm-9">
                        <input id="At_RegisteredPlan" type="text" class="form-control" placeholder="请输入计划登记户(户)" autofocus="autofocus" datacol="yes" err="计划登记户" checkexpession="Num">
                    </div>
                </div>               
                <div class="layui-form-item">
                    <label class="col-sm-3 layui-form-label">计划税收收入：</label>
                    <div class="col-sm-9">
                        <input id="At_RevenuePlan" type="text" class="form-control" placeholder="请输入计划税收收入（万元）" autofocus="autofocus" datacol="yes" err="计划税收收入" checkexpession="Num">
                    </div>
                </div>
              </form>
            <div class="box-footer">
                <button type="submit" id="btnSure" class="btn btn-info pull-right">
                    <i class="fa fa-check"></i>提交
                </button>
            </div>
        </div>
    </div>
  

    <!-- 查询模态框 -->
    @using (Html.BeginForm("Zor_AnnualTask", "Base", new RouteValueDictionary { { "Model", Model } }, FormMethod.Get))
    {
       <div id="myModalSearch" hidden data-backdrop="static">
        <div id="divfrom" class="layui-tab-content">    
                                <div class="layui-form-item">
                                    <label class="col-sm-2 layui-form-label">
                                        <nobr>街道办名称：</nobr>
                                    </label>
                                    <div class="col-sm-4">
                                        <select name="At_StreetName" class="form-control At_StreetName" id="At_StreetNames"></select>
                                        <script>
                                            $(function () {
                                                var html = "<option value=''>全部</option>";
                                                getAjax("/Base/SelectStreet", "", function (data) {
                                                    accordionJson = eval("(" + data + ")");
                                                    $.each(accordionJson, function (i) {
                                                        var nbsp = ""
                                                        html += "<option value='" + accordionJson[i].Dt_Id + "' >" + nbsp + accordionJson[i].Dt_Name + "</option>";
                                                    });
                                                });
                                                $(".At_StreetName").empty().append(html);
                                            });
                                        </script>
                                    </div>

                                    <label class="col-sm-2 layui-form-label">
                                        <nobr>年份：</nobr>
                                    </label>
                                    <div class="col-sm-4">
                                        <select name="At_Year" class="form-control" id="At_Years">
                                            <option value="">  全部     </option>
                                            @for (var i = DateTime.Now.Year; i <= DateTime.Now.Year + 12; i++)
                                            {
                                                <option value=@i>
                                                    @i 年
                                                </option>
                                            }
                                        </select>
                                    </div>
                                </div>                          
                            <div class="box-footer">
                                <button type="submit" class="btn btn-info pull-right">
                                    <i class="fa fa-search"></i>查询
                                </button>
                            </div>

                        </div>
                    </div>             
    }
</body>

</html>
<script type="text/javascript">


    /*刷新*/

    $("#btnRefresh").click(function () {
        Replace();
    });

    /*查询*/

    $("#btnSearchFull").click(function () {
        LayerOpen('600px', '200px', '查询条件', $('#myModalSearch'));
    });
    /*** 年度计划任务新增*/

    $(function () {
      
        $("#btnAdd").click(function () {          
            GetStreet(); //所有街道
            LayerOpen('600px', '320px', '年度计划任务新增', $('#myModal'));
        })

        /*保存*/      
        $("#btnSure").click(function () {

            if (!CheckDataValid('.form-horizontal')) {
                return false;
            }
            var JsData = GetWebControls(divfrom);
            ZorPostSimpleData("/Base/AddAlterAnnualTask", JSON.stringify({ "task": JsData }), function (data) {
                layer.msg(data.AnswerMeg, function () {
                    layer.closeAll();
                    Replace();
                });
            });

        });    

        /**修改用户 */

        $("#btnUpdate").click(function () {
            var checkId = CheckboxValueIDs();            
            if (checkId.length == 0) {
                layer.msg("请选择要修改的信息！");
                return;
            }
            if (checkId.length > 1) {
                layer.msg("仅可选择一行信息修改！");
                return;
            }
            GetStreet();                                      //所有行业
          
            $("#At_Id").val(getTableCell(0));
            $("#At_StreetName").val(getTableCell(3));
            $("#At_RegisteredPlan").val(getTableCell(4));
            $("#At_RevenuePlan").val(getTableCell(6));
            $("#At_Year").val(getTableCell(7));
            LayerOpen('600px', '320px', '年度计划任务编辑', $('#myModal'));

        })     

    /** 删除租户*/

        $("#btnDelete").click(function () {
            var checkId = CheckboxValueIDs();
            if (checkId.length == 0) {
                layer.msg("请选择要删除的租户！");                                                             //未选中任何行
                return;
            }
            else {
                layer.confirm("确定要删除吗?", { icon: 2, btn: ['确定', '取消'] }, function () {
                    ZorPostSimpleData("/Base/DeleteAnnualTask", JSON.stringify({ 'Id': checkId }), function (data) { //获取数据(带参数)
                        layer.msg(data.AnswerMeg, function () {
                            layer.closeAll();
                            Replace();
                        });
                    })
                })
            }
        })
    })

    /**
    * 查询所有街道
    */
    function GetStreet() {
        var html = "";
        getAjax("/Base/SelectStreet", "", function (data) {
            accordionJson = eval("(" + data + ")");
            $.each(accordionJson, function (i) {
                var nbsp = ""
                html += "<option value='" + accordionJson[i].Dt_Id + "' >" + nbsp + accordionJson[i].Dt_Name + "</option>";
            });
        });
        $("#At_StreetName").empty().append(html);
    }   

    /**
     * 全选
     */
    $(function () {
        $("#cbkCheckAll").click(function () {
            if (this.checked) {
                $("input[name='chk']").prop('checked', true);
            } else {
                $("input[name='chk']").prop('checked', false);
            }
        })
    })
</script>
